package controllers.validation.utils;

import util.UnitConverter;
import ch.bfh.abcm.rems.sensors.tinkerforge.TFSensorType;

public class MessageTextController {

    public String getSensorNotRespondingMesssage(String sensorUid, String measurementIP, TFSensorType sensorType) {
        // return "SENSOR_NOT_RESPONDING [MP: " + measurementIP + "] [T: " +
        // sensorType + "] [UID: " + sensorUid + "]";
        return "Sensor antwortet nicht \n [MP: " + measurementIP + "] [T: " + sensorType + "] [UID: " + sensorUid + "]";
    }

    public String getSensorRespondingMesssage(String sensorUid, String measurementIP, TFSensorType sensorType) {
        return "SENSOR_RESPONDING [MP: " + measurementIP + "] [T: " + sensorType + "] [UID: " + sensorUid + "]";
    }

    public String getSensorDivergentOutOfRangeMessage(String measurementIP, TFSensorType sensorType, int diff,
            int maxdiff) {
        int normDiff = UnitConverter.convertTFValuetoNormValue(sensorType, sensorType.getDecimalDigits(), diff);
        int normMaxDiff = UnitConverter.convertTFValuetoNormValue(sensorType, sensorType.getDecimalDigits(), maxdiff);
        return "Sensorwerte Ausserhalb der Abweichungstoleranz \n [" + sensorType+ "] \n"
                + " [DIFF: " + normDiff + " > MAXDIFF: " + normMaxDiff + "]";
    }

    public String getSensorDivergentInRangeMessage(String measurementIP, TFSensorType sensorType, int diff, int maxdiff) {
        int normDiff = UnitConverter.convertTFValuetoNormValue(sensorType, sensorType.getDecimalDigits(), diff);
        int normMaxDiff = UnitConverter.convertTFValuetoNormValue(sensorType, sensorType.getDecimalDigits(), maxdiff);
        return "SENSOR_VALUES_IN_RANGE [MP: " + measurementIP + "] [T: " + sensorType + "] [DIFF: " + normDiff
                + " > MAXDIFF: " + normMaxDiff + "]";
    }

    public String getMeasurementPointNotRespondingMesssage(String MeasurementPoint) {
        return "Messpunkt Antwortet nicht \n [" + MeasurementPoint + "]";
        
    }
    
    public String getNodeNotRespondingMesssage(String node) {
        // return "NODE_NOT_RESPONDING [N:" + node + "] [SensorType: " +
        // sensorType + "]";
        return "NODE Antwortet nicht \n [" + node + "]";

    }

    public String getNodeRespondingMesssage(String node, TFSensorType sensorType) {
        return "NODE_RESPONDING [N:" + node + "] [SensorType: " + sensorType + "]";
    }

    public String getMesurementPointOutOfRangeMessage(String measurementIP, TFSensorType sensorType, int min, int max,
            int effective) {
        int normEff = UnitConverter.convertTFValuetoNormValue(sensorType, sensorType.getDecimalDigits(), effective);
        int normMin = UnitConverter.convertTFValuetoNormValue(sensorType, sensorType.getDecimalDigits(), min);
        int normMax = UnitConverter.convertTFValuetoNormValue(sensorType, sensorType.getDecimalDigits(), max);
        return "Schwellwertabweichung: " + normEff + " " + sensorType.getUnit() + "\n [MIN: " + normMin + " MAX: "
                + normMax + "]";
    }

    public String getMesurementPointInRangeMessage(String measurementpoint, TFSensorType sensorType, int min, int max,
            int effective) {
        int normEff = UnitConverter.convertTFValuetoNormValue(sensorType, sensorType.getDecimalDigits(), effective);
        int normMin = UnitConverter.convertTFValuetoNormValue(sensorType, sensorType.getDecimalDigits(), min);
        int normMax = UnitConverter.convertTFValuetoNormValue(sensorType, sensorType.getDecimalDigits(), max);
        return "MP_MEASUREMENT_IN_RANGE [MP: " + measurementpoint + "] [T: " + sensorType + "] [MIN: " + normMin
                + " MAX: " + normMax + " AVG: " + normEff + "]";
    }

    public String getMesurementPointOKMessage(String measurementpoint, TFSensorType sensorType, int effective) {
        return "System OK";
    }

}
